package cn.ac.iscas.chinesesegmentme;

import java.util.Vector;

public class Statisticer {
	private int length = 20;
	private int[] wl;
	
	
	public Statisticer(int length){
		this.length = length;
		wl = new int[length];
		for (int i = 0; i < length; i++) wl[i] = 0;
	}
	
	public void printStatistic(){
		System.out.println("WordLength\tWordFreq");
		for (int i = 0; i < length; i++){
			System.out.println((i+1) + "\t" + wl[i]);
		}
	}
	
	public void statisticLine(String line){
		String[] tmp = line.split("\\|");
		for (int i = 0; i < tmp.length; i++){
			String tmpStr = tmp[i].trim();
			if (tmpStr.length() > 0){
				String[] tmp2 = tmpStr.split(" ");
				if (tmp2.length <= length && tmp2.length > 0){
					wl[tmp2.length-1]++;
				}
			}
		}
	}
}
